package com.boang.controller;

import com.boang.domain.Spu;
import com.boang.service.SpuService;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.ModelMap;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

/*
  @author: 13813
  @date: 2024/8/8 9:27
*/
@Controller
@RequestMapping("/page/spu")
@Tag(name = "商品控制器", description = "商品的CRUD")
public class SpuPageController {

    @Autowired
    private SpuService service;

    @GetMapping("/getSpuList")
    @Operation(description = "商品列表")
    public String getSpuList(ModelMap modelMap) {
        List<Spu> list = service.list();
        modelMap.put("list", list);
        modelMap.put("spuPrice", 999);
        return "spu_list";
    }

    @DeleteMapping("/removeSpuById")
    public boolean removeSpuById(int spuId) {
        return service.removeById(spuId);
    }
}
